package com.example.security.controller.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.security.entity.sys.SysLog;
import com.example.security.service.sys.ISysLogService;
import com.example.security.vo.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/log")
public class SysLogController {

    @Autowired
    private ISysLogService sysLogService;

    @PreAuthorize("hasAuthority('sys:log:view')")
    @PostMapping(value="/findPage")
    public ResponseEntity<IPage<SysLog>>  findPage(@RequestBody PageRequest pageRequest) {
        return ResponseEntity.ok(sysLogService.page(new Page<>(pageRequest.getPageNum(), pageRequest.getPageSize())));
    }
}
